/*
 * main.cpp
 *
 *  Created on: Jan 26, 2012
 *      Author: beebe
 */

#include "LinkedList.h"
#include "BST.h"
#include <assert.h>
#include <iostream>
using namespace std;

void testBST(){
	BST * tree = new BST();
	tree->Insert("hello2");
	tree->Insert("hello");
	tree->Insert("hello3");
	tree->Insert("hello5");
	tree->Insert("hello4");
	string value4 = tree->Find("hello4")->GetValue();
	BST * tree2 = new BST(*tree);
	tree->Insert("new");
	assert(tree2->Find("new")==NULL);
	BST tree3 = *tree2;
	assert(tree3.Find("hello2")!=NULL);
	tree2->Insert("new");
	assert(tree3.Find("new")==NULL);
	delete(tree);
	delete(tree2);
}
void testLL(){
	LinkedList * ll = new LinkedList();
	LLNode * node1 = ll->Insert("hello",NULL);
	ll->Insert("hello2",NULL);
	LLNode * node3 = ll->Insert("hello3",NULL);
	LLNode * node4 = ll->Insert("hello4",node3);
	LLNode * node2 = ll->Find("hello2",node3);
	LinkedList * ll2 = new LinkedList(*ll);
	ll->Insert("new",node3);
	assert(ll2->Find("new",NULL)==NULL);
	LinkedList ll3 = *ll2;
	ll2->Insert("hello5",NULL);
	assert(ll3.Find("hello5",NULL)==NULL);

	ll->Remove(node2);
	ll->Remove(node1);
	ll->Remove(node3);
	ll->Remove(node4);
	assert(ll->GetSize()==1);
	delete(ll);
	delete(ll2);
}
int main(){
	testLL();
	testBST();
	cout << "Test Completed Without Errors.";
	return 0;

}
